package main;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import util.Util;
import util.graficos.GraficoVazao;

public class GeradorVazao {
	
	private static GraficoVazao graficoVazao;

	public static void main(String[] args) {
		graficoVazao = new GraficoVazao();
		
		FileReader fileReader;
		try {
			fileReader = new FileReader(Util.ARQUIVO_VAZAO);
			BufferedReader bufferedReader = new BufferedReader(fileReader);
			
			String linha;
			while ((linha = bufferedReader.readLine()) != null) {
				String[] strings = linha.split(" ");
				
				double mediaVazao = Double.parseDouble(strings[0]);
				double varianciaVazao = Double.parseDouble(strings[1]);
				int n0 = Integer.parseInt(strings[2]);
				
				if (Util.PLOTAR_GRAFICOS) {
					graficoVazao.adicionaRodada(mediaVazao, varianciaVazao, n0);
				}
			}
			
			if (Util.PLOTAR_GRAFICOS) {
				graficoVazao.plot();
			}
			
			// ao conluir o plot, apaga o arquivo
			File file = new File(Util.ARQUIVO_VAZAO);
			file.delete();
		}
		catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		catch (IOException e) {
			e.printStackTrace();
		}
	}

}
